home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / Ang261Lib.lha / src / potions.c < prev    next >
C/C++ Source or Header  |  1994-10-22  |  12KB  |  504 lines

  1. /*
  2.  * potions.c: code for potions 
  3.  *
  4.  * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke 
  5.  *
  6.  * This software may be copied and distributed for educational, research, and
  7.  * not for profit purposes provided that this copyright and statement are
  8.  * included in all such copies. 
  9.  */
  10.  
  11. #include "constant.h"
  12. #include "config.h"
  13. #include "types.h"
  14. #include "externs.h"
  15.  
  16. #ifdef USG
  17. #include <string.h>
  18. #else
  19. #include <strings.h>
  20. #endif
  21.  
  22. /* Potions for the quaffing                -RAK-     */
  23. void 
  24. quaff()
  25. {
  26.     int32u i, l;
  27.     int    j, k, item_val;
  28.     int    ident;
  29.     register inven_type   *i_ptr;
  30.     register struct misc  *m_ptr;
  31.     register struct flags *f_ptr;
  32.  
  33.     free_turn_flag = TRUE;
  34.     if (inven_ctr == 0)
  35.     msg_print("But you are not carrying anything.");
  36.     else if (!find_range(TV_POTION1, TV_POTION2, &j, &k))
  37.     msg_print("You are not carrying any potions.");
  38.     else if (get_item(&item_val, "Quaff which potion?", j, k, 0)) {
  39.     i_ptr = &inventory[item_val];
  40.     i = i_ptr->flags;
  41.     free_turn_flag = FALSE;
  42.     ident = FALSE;
  43.     if (i == 0) {
  44.         msg_print("You feel less thirsty.");
  45.         ident = TRUE;
  46.     } else
  47.         while (i != 0) {
  48.         j = bit_pos(&i) + 1;
  49.         if (i_ptr->tval == TV_POTION2)
  50.             j += 32;
  51.         /* Potions                         */
  52.         switch (j) {
  53.           case 1:
  54.             if (inc_stat(A_STR)) {
  55.             msg_print("Wow!  What bulging muscles! ");
  56.             ident = TRUE;
  57.             }
  58.             break;
  59.           case 2:
  60.             ident = TRUE;
  61.             lose_str();
  62.             break;
  63.           case 3:
  64.             if (res_stat(A_STR)) {
  65.             msg_print("You feel warm all over.");
  66.             ident = TRUE;
  67.             }
  68.             break;
  69.           case 4:
  70.             if (inc_stat(A_INT)) {
  71.             msg_print("Aren't you brilliant! ");
  72.             ident = TRUE;
  73.             }
  74.             break;
  75.           case 5:
  76.             ident = TRUE;
  77.             lose_int();
  78.             break;
  79.           case 6:
  80.             if (res_stat(A_INT)) {
  81.             msg_print("You have a warm feeling.");
  82.             ident = TRUE;
  83.             }
  84.             break;
  85.           case 7:
  86.             if (inc_stat(A_WIS)) {
  87.             msg_print("You suddenly have a profound thought! ");
  88.             ident = TRUE;
  89.             }
  90.             break;
  91.           case 8:
  92.             ident = TRUE;
  93.             lose_wis();
  94.             break;
  95.           case 9:
  96.             if (res_stat(A_WIS)) {
  97.             msg_print("You feel your wisdom returning.");
  98.             ident = TRUE;
  99.             }
  100.             break;
  101.           case 10:
  102.             if (inc_stat(A_CHR)) {
  103.             msg_print("Gee, ain't you cute! ");
  104.             ident = TRUE;
  105.             }
  106.             break;
  107.           case 11:
  108.             ident = TRUE;
  109.             lose_chr();
  110.             break;
  111.           case 12:
  112.             if (res_stat(A_CHR)) {
  113.             msg_print("You feel your looks returning.");
  114.             ident = TRUE;
  115.             }
  116.             break;
  117.           case 13:
  118.             if (hp_player(damroll(2, 7)))
  119.             ident = TRUE;
  120.             if (py.flags.cut > 0) {
  121.             py.flags.cut -= 10;
  122.             if (py.flags.cut < 0)
  123.                 py.flags.cut = 0;
  124.             ident = TRUE;
  125.             msg_print("Your wounds heal.");
  126.             }
  127.             break;
  128.           case 14:
  129.             if (hp_player(damroll(4, 7)))
  130.             ident = TRUE;
  131.             if (py.flags.cut > 0) {
  132.             py.flags.cut = (py.flags.cut / 2) - 50;
  133.             if (py.flags.cut < 0)
  134.                 py.flags.cut = 0;
  135.             ident = TRUE;
  136.             msg_print("Your wounds heal.");
  137.             }
  138.             break;
  139.           case 15:
  140.             if (hp_player(damroll(6, 7)))
  141.             ident = TRUE;
  142.             if (py.flags.cut > 0) {
  143.             py.flags.cut = 0;
  144.             ident = TRUE;
  145.             msg_print("Your wounds heal.");
  146.             }
  147.             if (py.flags.stun > 0) {
  148.             if (py.flags.stun > 50) {
  149.                 py.misc.ptohit += 20;
  150.                 py.misc.ptodam += 20;
  151.             } else {
  152.                 py.misc.ptohit += 5;
  153.                 py.misc.ptodam += 5;
  154.             }
  155.             py.flags.stun = 0;
  156.             ident = TRUE;
  157.             msg_print("Your head stops stinging.");
  158.             }
  159.             break;
  160.           case 16:
  161.             if (hp_player(400))
  162.             ident = TRUE;
  163.             if (py.flags.stun > 0) {
  164.             if (py.flags.stun > 50) {
  165.                 py.misc.ptohit += 20;
  166.                 py.misc.ptodam += 20;
  167.             } else {
  168.                 py.misc.ptohit += 5;
  169.                 py.misc.ptodam += 5;
  170.             }
  171.             py.flags.stun = 0;
  172.             ident = TRUE;
  173.             msg_print("Your head stops stinging.");
  174.             }
  175.             if (py.flags.cut > 0) {
  176.             py.flags.cut = 0;
  177.             ident = TRUE;
  178.             msg_print("Your wounds heal.");
  179.             }
  180.             break;
  181.           case 17:
  182.             if (inc_stat(A_CON)) {
  183.             msg_print("You feel tingly for a moment.");
  184.             ident = TRUE;
  185.             }
  186.             break;
  187.           case 18:
  188.             m_ptr = &py.misc;
  189.             if (m_ptr->exp < MAX_EXP) {
  190.             l = (m_ptr->exp / 2) + 10;
  191.             if (l > 100000L)
  192.                 l = 100000L;
  193.             m_ptr->exp += l;
  194.             msg_print("You feel more experienced.");
  195.             prt_experience();
  196.             ident = TRUE;
  197.             }
  198.             break;
  199.           case 19:
  200.             f_ptr = &py.flags;
  201.             if (!f_ptr->free_act) {
  202.             /* paralysis must == 0, otherwise could not drink potion */
  203.             msg_print("You fall asleep.");
  204.             f_ptr->paralysis += randint(4) + 4;
  205.             ident = TRUE;
  206.             }
  207.             break;
  208.           case 20:
  209.             f_ptr = &py.flags;
  210.             if (!py.flags.blindness_resist) {
  211.             if (f_ptr->blind == 0) {
  212.                 msg_print("You are covered by a veil of darkness.");
  213.                 ident = TRUE;
  214.             }
  215.             f_ptr->blind += randint(100) + 100;
  216.             }
  217.             break;
  218.           case 21:
  219.             f_ptr = &py.flags;
  220.             if (!f_ptr->confusion_resist) {
  221.             if (f_ptr->confused == 0) {
  222.                 msg_print("Hey!  This is good stuff!  * Hick! *");
  223.                 ident = TRUE;
  224.             }
  225.             f_ptr->confused += randint(20) + 12;
  226.             }
  227.             break;
  228.           case 22:
  229.             f_ptr = &py.flags;
  230.             if (!(f_ptr->poison_im || f_ptr->poison_resist ||
  231.               f_ptr->resist_poison)) {
  232.             msg_print("You feel very sick.");
  233.             f_ptr->poisoned += randint(15) + 10;
  234.             } else
  235.             msg_print("The poison has no effect.");
  236.             if (!f_ptr->poison_resist)
  237.             ident = TRUE;
  238.             break;
  239.           case 23:
  240.             if (py.flags.fast == 0)
  241.             ident = TRUE;
  242.             if (py.flags.fast <= 0) {
  243.             py.flags.fast += randint(25) + 15;
  244.             } else
  245.             py.flags.fast += randint(5);
  246.             break;
  247.           case 24:
  248.             if (py.flags.slow == 0)
  249.             ident = TRUE;
  250.             py.flags.slow += randint(25) + 15;
  251.             break;
  252.           case 26:
  253.             if (inc_stat(A_DEX)) {
  254.             msg_print("You feel more limber! ");
  255.             ident = TRUE;
  256.             }
  257.             break;
  258.           case 27:
  259.             if (res_stat(A_DEX)) {
  260.             msg_print("You feel less clumsy.");
  261.             ident = TRUE;
  262.             }
  263.             break;
  264.           case 28:
  265.             if (res_stat(A_CON)) {
  266.             msg_print("You feel your health returning! ");
  267.             ident = TRUE;
  268.             }
  269.             break;
  270.           case 29:
  271.             if (cure_blindness())
  272.             ident = TRUE;
  273.             break;
  274.           case 30:
  275.             if (cure_confusion())
  276.             ident = TRUE;
  277.             break;
  278.           case 31:
  279.             if (cure_poison())
  280.             ident = TRUE;
  281.             break;
  282.           case 34:
  283.             ident = TRUE;
  284.             if (!py.flags.hold_life && py.misc.exp > 0) {
  285.             int32               m, scale;
  286.  
  287.             msg_print("You feel your memories fade.");
  288.             m = py.misc.exp / 5;
  289.             if (py.misc.exp > MAX_SHORT) {
  290.                 scale = MAX_LONG / py.misc.exp;
  291.                 m += (randint((int)scale) * py.misc.exp) / (scale * 5);
  292.             } else
  293.                 m += randint((int)py.misc.exp) / 5;
  294.             lose_exp(m);
  295.             } else
  296.             msg_print
  297.         ("You feel you memories fade for a moment, but quickly return.");
  298.             break;
  299.           case 35:
  300.             f_ptr = &py.flags;
  301.             (void)cure_poison();
  302.             if (f_ptr->food > 150)
  303.             f_ptr->food = 150;
  304.             f_ptr->paralysis = 4;
  305.             msg_print("The potion makes you vomit! ");
  306.             ident = TRUE;
  307.             break;
  308.           case 37:
  309.             if (py.flags.hero == 0)
  310.             ident = TRUE;
  311.             py.flags.hero += randint(25) + 25;
  312.             break;
  313.           case 38:
  314.             if (py.flags.shero == 0)
  315.             ident = TRUE;
  316.             py.flags.shero += randint(25) + 25;
  317.             break;
  318.           case 39:
  319.             if (remove_fear())
  320.             ident = TRUE;
  321.             break;
  322.           case 40:
  323.             if (restore_level())
  324.             ident = TRUE;
  325.             break;
  326.           case 41:
  327.             f_ptr = &py.flags;
  328.             if (f_ptr->resist_heat == 0)
  329.             ident = TRUE;
  330.             f_ptr->resist_heat += randint(10) + 10;
  331.             break;
  332.           case 42:
  333.             f_ptr = &py.flags;
  334.             if (f_ptr->resist_cold == 0)
  335.             ident = TRUE;
  336.             f_ptr->resist_cold += randint(10) + 10;
  337.             break;
  338.           case 43:
  339.             if (py.flags.detect_inv == 0)
  340.             ident = TRUE;
  341.             detect_inv2(randint(12) + 12);
  342.             break;
  343.           case 44:
  344.             if (slow_poison())
  345.             ident = TRUE;
  346.             break;
  347.           case 45:
  348.             if (cure_poison())
  349.             ident = TRUE;
  350.             break;
  351.           case 46:
  352.             m_ptr = &py.misc;
  353.             if (m_ptr->cmana < m_ptr->mana) {
  354.             m_ptr->cmana = m_ptr->mana;
  355.             ident = TRUE;
  356.             msg_print("Your feel your head clear.");
  357.             prt_cmana();
  358.             }
  359.             break;
  360.           case 47:
  361.             f_ptr = &py.flags;
  362.             if (f_ptr->tim_infra == 0) {
  363.             msg_print("Your eyes begin to tingle.");
  364.             ident = TRUE;
  365.             }
  366.             f_ptr->tim_infra += 100 + randint(100);
  367.             break;
  368.           case 48:
  369.             wizard_light(TRUE);
  370.             if (!res_stat(A_WIS))
  371.             inc_stat(A_WIS);
  372.             if (!res_stat(A_INT))
  373.             inc_stat(A_INT);
  374.             msg_print("You feel more enlightened! ");
  375.             msg_print(NULL);
  376.             self_knowledge();    /* after all, what is the key to
  377.                      * enlightenment? -CFT */
  378.             identify_pack();
  379.             (void)detect_treasure();
  380.             (void)detect_object();
  381.             (void)detect_sdoor();
  382.             (void)detect_trap();
  383.             ident = TRUE;
  384.             break;
  385.           case 49:
  386.             msg_print("Massive explosions rupture your body! ");
  387.             take_hit(damroll(50, 20), "a potion of Detonation");
  388.             cut_player(5000);
  389.             stun_player(75);
  390.             ident = TRUE;
  391.             break;
  392.           case 50:       /* Death */
  393.             msg_print("A feeling of Death flows through your body.");
  394.             take_hit(5000, "a potion of Death");
  395.             ident = TRUE;
  396.             break;
  397.           case 51:       /* Life */
  398.             if (restore_level() | res_stat(A_STR) | res_stat(A_CON) |
  399.             res_stat(A_DEX) | res_stat(A_WIS) | res_stat(A_INT) |
  400.             res_stat(A_CHR) | hp_player(5000) | cure_poison() |
  401.             cure_blindness() | cure_confusion() | (py.flags.stun > 0) |
  402.             (py.flags.cut > 0) | (py.flags.image > 0) | remove_fear()) {
  403.             ident = TRUE;
  404.             py.flags.cut = 0;
  405.             py.flags.image = 0;
  406.             if (py.flags.stun > 0) {
  407.                 if (py.flags.stun > 50) {
  408.                 py.misc.ptohit += 20;
  409.                 py.misc.ptodam += 20;
  410.                 } else {
  411.                 py.misc.ptohit += 5;
  412.                 py.misc.ptodam += 5;
  413.                 }
  414.                 py.flags.stun = 0;
  415.             }
  416.             }
  417.             break;
  418.           case 52:       /* Augm */
  419.             if (inc_stat(A_DEX) | inc_stat(A_WIS) | inc_stat(A_INT) |
  420.               inc_stat(A_STR) | inc_stat(A_CHR) | inc_stat(A_CON)) {
  421.             ident = TRUE;
  422.             msg_print("You feel power flow through your body! ");
  423.             }
  424.             break;
  425.           case 53:       /* Ruination */
  426.             take_hit(damroll(10, 10), "a potion of Ruination");
  427.             ruin_stat(A_DEX);
  428.             ruin_stat(A_WIS);
  429.             ruin_stat(A_CON);
  430.             ruin_stat(A_STR);
  431.             ruin_stat(A_CHR);
  432.             ruin_stat(A_INT);
  433.             ident = TRUE;
  434.             msg_print("Your nerves and muscles feel weak and lifeless! ");
  435.             break;
  436.           case 54:
  437.             msg_print("An image of your surroundings forms in your mind...");
  438.             wizard_light(TRUE);
  439.             ident = TRUE;
  440.             break;
  441.           case 55:
  442.             msg_print("You feel you know yourself a little better...");
  443.             msg_print(NULL);
  444.             self_knowledge();
  445.             ident = TRUE;
  446.             break;
  447.           case 56:       /* *Healing*  */
  448.             if (hp_player(1200))
  449.             ident = TRUE;
  450.             if (py.flags.stun > 0) {
  451.             if (py.flags.stun > 50) {
  452.                 py.misc.ptohit += 20;
  453.                 py.misc.ptodam += 20;
  454.             } else {
  455.                 py.misc.ptohit += 5;
  456.                 py.misc.ptodam += 5;
  457.             }
  458.             py.flags.stun = 0;
  459.             ident = TRUE;
  460.             msg_print("Your head stops stinging.");
  461.             }
  462.             if (py.flags.cut > 0) {
  463.             py.flags.cut = 0;
  464.             ident = TRUE;
  465.             msg_print("Your wounds heal.");
  466.             }
  467.             if (cure_blindness())
  468.             ident = TRUE;
  469.             if (cure_confusion())
  470.             ident = TRUE;
  471.             if (cure_poison())
  472.             ident = TRUE;
  473.             break;
  474.           default:
  475.             if (1) {
  476.             char                tmp_str[100];
  477.  
  478.             msg_print("Internal error in potion()");
  479.             sprintf(tmp_str, "Number %d...", j);
  480.             msg_print(tmp_str);
  481.             }
  482.             break;
  483.         }
  484.         /* End of Potions.                     */
  485.         }
  486.     if (ident) {
  487.         if (!known1_p(i_ptr)) {
  488.         m_ptr = &py.misc;
  489.         /* round half-way case up */
  490.         m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) / m_ptr->lev;
  491.         prt_experience();
  492.  
  493.         identify(&item_val);
  494.         i_ptr = &inventory[item_val];
  495.         }
  496.     } else if (!known1_p(i_ptr))
  497.         sample(i_ptr);
  498.  
  499.     add_food(i_ptr->p1);
  500.     desc_remain(item_val);
  501.     inven_destroy(item_val);
  502.     }
  503. }
  504.